package javase0825;

import javase0825.demo05.Foo;

public class Demo05 {
    int n = 2000;
    public synchronized void jianshao() {
        n--;
    }

    public  void zengjia() {
        synchronized (this) {
            n++;
        }
    }


    public static void main(String[] args) {
        /*
        账号：foo   该账号已注册、不合法  对勾
        密码：mima
        重复密码
        验证码
        确定

        获取一个数据 {id：1，name:null, age:0}
        启用了一个方法 通过id=1 查询具体内容
                    name：foo

        输出对象：   {id：1，name:null, age:0}


         */

        Demo05 d = new Demo05();
        System.out.println(d.n);
        //完成1000个
        /*for (int i = 0; i < 1000; i++) {
            d.jianshao();
        }
        System.out.println(d.n);*/
        Thread t1 = new Foo(d);
        //完成1000个
        /*for (int i = 0; i < 1000; i++) {
            d.jianshao();
        }
        System.out.println(d.n);*/
        Thread t2 = new Foo(d);
        t1.start();
        t2.start();
        /*try {
            Thread.sleep(10000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }*/
        try {
            t1.join();
            t2.join();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }

        System.out.println(d.n);

        StringBuilder sb1 = null;
        StringBuffer sb2 = null;
    }
}
